<?php
// 本类由系统自动生成，仅供测试用途
class ServiceAction extends Action {
     public function index(){
		R('Index/indexpic');
		$this->xinliintro();
		$this->xueyeintro();
		$this->liuyanintro();
		$this->ddtsintro();
        $this->display();
    }
	private function xinliintro(){
		$model=M('article');
		$cond['type']="心理咨询服务介绍";
		$index=$model->where($cond)->select();
		$this->assign('xinliintro',$index[0]['content']);
		$this->assign('xlid',$index[0]['id']);
	}
	private function xueyeintro(){
		$model=M('article');
		$cond['type']="学业指导服务介绍";
		$index=$model->where($cond)->select();
		$this->assign('xueyeintro',$index[0]['content']);
		$this->assign('xyid',$index[0]['id']);
	}
	private function liuyanintro(){
		$model=M('article');
		$cond['type']="留言咨询";
		$index=$model->where($cond)->select();
		$this->assign('liuyanintro',$index[0]['content']);
		$this->assign('lyid',$index[0]['id']);
	}
	private function ddtsintro(){
		$model=M('article');
		$cond['type']="对大厅说";
		$index=$model->where($cond)->select();
		$this->assign('ddtsintro',$index[0]['content']);
		$this->assign('dtid',$index[0]['id']);
	}

	//心理咨询
	public function xlzd(){
		R('Index/indexpic');
		$model=M('article');
		$cond['type']='个体心理咨询';
		$index=$model->where($cond)->select();
		$this->assign('gtxl',$index[0]['content']);
		$this->xljiti();
		$this->display();
	}
	//集体咨询预约
	private function xljiti(){
		$model=M('jiti');
		$cond['type']='心理';
		$cond['state']='报名中';
		import("ORG.Util.Page");//导入分页类
		$index=$model->where($cond)->count();
		$Page = new Page($index,1);//实例化分页类传入总记录数和每页显示的记录数
		$show = $Page->show();//分页显示输出
		//进行分页数据查询注意limit方法的参数要使用Page类的属性
		$list = $model->where($cond)->order('id DESC')->limit($Page->firstRow.','.$Page->listRows)->select();
		$this->assign('list',$list);
		$this->assign('page',$show);//赋值分页输出
	}
	//一对一心理咨询
	public function xlzdyy(){
		R('Index/indexpic');
		$this->display();
	}

	public function xinliyy(){
		R('Index/indexpic');
		$model=M('c-order');
		$time=$_POST['month'].$_POST['day'].$_POST['hour'];
		$data=array(
		'name'=>$_POST['name'],
		'stdNo'=>$_POST['stdNo'],
		'mobile'=>$_POST['mobile'],
		'school'=>$_POST['school'],
		'time'=>$time,
		'uptime'=>time(),
		'question'=>$_POST['liuyan'],
		'type'=>'心理'
		);
		$list=$model->add($data);
		 if ($list !== false) {
            $this->assign('message','您好，您已预约成功，我们会尽快处理。<br>如有疑问请联系010- 51685957。');
			$this->display('xlzdyy');
        } else {
            $this->error('请联系010- 51685957!');
        }
	}
	//学业指导
	public function xyzd(){
		R('Index/indexpic');
		$model=M('article');
		$cond['type']='个体学业咨询';
		$index=$model->where($cond)->select();
		$this->assign('gtxy',$index[0]['content']);
		$this->xyjiti();
		$this->display();
	}
	//集体咨询预约
	private function xyjiti(){
		$model=M('jiti');
		$cond['type']='学业';
		$cond['state']='报名中';
		import("ORG.Util.Page");//导入分页类
		$index=$model->where($cond)->count();
		$Page = new Page($index,1);//实例化分页类传入总记录数和每页显示的记录数
		$show = $Page->show();//分页显示输出
		//进行分页数据查询注意limit方法的参数要使用Page类的属性
		$list = $model->where($cond)->order('id DESC')->limit($Page->firstRow.','.$Page->listRows)->select();
		$this->assign('list',$list);
		$this->assign('page',$show);//赋值分页输出
	}
	//一对一学业指导
	public function xyzdyy(){
		R('Index/indexpic');
		$this->display();
	}
	public function xueyeyy(){
		R('Index/indexpic');
		$model=M('c-order');
		$time=$_POST['month'].$_POST['day'].$_POST['hour'];
		$data=array(
		'name'=>$_POST['name'],
		'stdNo'=>$_POST['stdNo'],
		'mobile'=>$_POST['mobile'],
		'school'=>$_POST['school'],
		'time'=>$time,
		'uptime'=>time(),
		'question'=>$_POST['liuyan'],
		'type'=>'学业'
		);
		$list=$model->add($data);
		 if ($list !== false) {
            $this->assign('message','您好，您已预约成功，我们会尽快处理。<br>如有疑问请联系010- 51685957。');
			$this->display('xyzdyy');
        } else {
            $this->error('请联系010- 51685957!');
        }
	}

	public function jiti(){
		R('Index/indexpic');
		$type=$_GET['type'];
		$model=M('h-order');
		$data=array(
		'hid'=>$_POST['hid'],
		'name'=>$_POST['name'],
		'stdNo'=>$_POST['stdNo'],
		'school'=>$_POST['school'],
		'grade'=>$_POST['grade'],
		'type'=>$type,
		'time'=>time()
		);
		$list=$model->add($data);
		if ($list !== false) {
            $this->assign('message','您好，您已预约成功，我们会尽快处理。如有疑问请联系010- 51685957。');
			if($type=='学业')
			{
				$this->display('xyzd');
			}
			else{
				$this->display('xlzd');
			}
        } else {
            $this->error('请联系010- 51685957!');
        }
	}
	//留言咨询
	public function lyzx(){
		R('Index/indexpic');
		$this->display();
	}
	public function liuyan(){
		R('Index/indexpic');
		$model=M('consult');
		$data=array(
			'name'=>$_POST['name'],
			'stdNo'=>$_POST['stdNo'],
			'school'=>$_POST['school'],
			'gangwei'=>$_POST['gangwei'],
			'content'=>$_POST['yewu'],
			'time'=>time()
		);
		$list=$model->add($data);
		if ($list !== false) {
            $this->assign('message','留言成功，我们会尽快将问题回复发送至您的邮箱。');
			$this->display('lyzx');
        } else {
            $this->error('请联系010- 51685957!');
        }
	}
	//对大厅说
	public function ddts(){
		R('Index/indexpic');
		$this->display();
	}
	public function duidatingshuo(){
		R('Index/indexpic');
		$model=M('advice');
		$data=array(
			'content'=>$_POST['content'],
			'time'=>time()
		);
		$list=$model->add($data);
		if ($list !== false) {
            $this->assign('message','感谢您对大厅工作的支持，我们会认真阅读您的意见和建议！<br>谢&nbsp;&nbsp;谢！');
			$this->display('ddts');
        } else {
            $this->error('请联系010- 51685957!');
        }
	}
}
?>